import { defineStore } from 'pinia'
import { ref } from 'vue'

export const CodeStore = defineStore(
    'code',
    () => {
        const data = ref({})
        const resetAllCodeStore = () => {
            data.value = {}
        }
        const addCodeStore = (key: string, value: any) => {
            data.value[key] = value
        }
        const removeCodeStore = (key: string) => {
            data.value[key] = null
        }
        const getCodeStore = (key: string) => {
            return data.value[key]
        }
        return { data, resetAllCodeStore, addCodeStore, removeCodeStore, getCodeStore }
    },
    {
        persist: {
            key: 'Code',
            storage: localStorage
        }
    }
)
